/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view;

import domain.controller.file.ImageController;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemCommandListener;
import javax.microedition.lcdui.Spacer;
import util.J2meAppHelper;

/**
 * @author victorinox
 */
public class InicialPortoSeguroForm extends InicialForm implements ItemCommandListener{

    private Form form = new Form("Catalogo Mobile");
    private Command cmdPortoSeguro = new Command("Entrar", Command.ITEM, 1);
    private Command cmdSair = new Command("Sair", Command.EXIT, 1);
    private ImageItem itemPortoSeguro = new ImageItem ("", ImageController.getInstance().getLogoImagem(), ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_VCENTER, "Unimed", Item.HYPERLINK);
    
    public InicialPortoSeguroForm() {
        super();
    }
    
    public Displayable getDisplyable() {
        return form;
    }
    
    public void initialize(Object parameter) {
        itemPortoSeguro.addCommand(cmdPortoSeguro);
        itemPortoSeguro.setDefaultCommand(cmdPortoSeguro);
        itemPortoSeguro.setItemCommandListener(this);
        
        form.setCommandListener(this);
        form.append(new Spacer(100, 10));
        form.append(itemPortoSeguro);
       
        form.addCommand(cmdSair);
        
    }

    public void commandAction(Command arg0, Item image) {
        if(image.equals(itemPortoSeguro)){
           J2meAppHelper.getInstance().changeForm(new CategoriaRaizForm(), true);
        }
    }
    
    

    public void commandAction(Command arg0, Displayable arg1) {
       if(arg0.equals(cmdSair)){
            J2meAppHelper.getInstance().getMidlet().exitMIDlet();
       }
    }
}
